<?php

if ($form_Content == "课室") {
    $mc->set($fromUsername . "_do", "课室", 0, 1000);
    $text = "输入需要查询的时间。指令依次为【一，二……六，日】\n\n输入【菜单】返回功能列表。";
    $resultStr = sprintf($textTpl, $fromUsername, $toUsername, 'text', $text);
    echo $resultStr;
    exit;
} else {
    if ($form_Content == "六" || $form_Content == "日") {
        $str = "星期";
        $form_Content = $str . $form_Content;
        $classroom = $mysql->getData("select * from classroom where DAY='$form_Content';");
        $title = $form_Content . "空课室";
        $content = "时间：全日\n\n北座:\n" . $classroom[0]['NCLASSROOM'] . "\n\n南座:\n" . $classroom[0]['SCLASSROOM'];
        $resultStr =
                "<xml>
           <ToUserName><![CDATA[$postObj->FromUserName]]></ToUserName>
           <FromUserName><![CDATA[$postObj->ToUserName]]></FromUserName>
           <CreateTime>" . time() . "</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>3</ArticleCount>
           <Articles>
           <item>
           <Title><![CDATA[$title]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b400.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/H2ksGQKGimJX0HCjpYYhvUsgktYiiXYFR5vpbINTNGs!/b/dD7Vcu6dDgAA&bo=*gEFAgAAAAABAN8!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
            <item>
           <Title><![CDATA[$content]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
            <item>
           <Title><![CDATA[输入【菜单】返回功能主页\n输入时间继续查询]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";
        echo $resultStr;
        $mc->set($fromUsername . "_do", "课室", 0, 600);
        exit;
    }
    if ($form_Content == "一" || $form_Content == "二" || $form_Content == "三" || $form_Content == "四" || $form_Content == "五") {


        $str = "星期";
        $form_Content = $str . $form_Content;
        $classroom = $mysql->getData("select * from classroom where DAY='$form_Content';");

        $resultStr = "<xml>
           <ToUserName><![CDATA[$postObj->FromUserName]]></ToUserName>
           <FromUserName><![CDATA[$postObj->ToUserName]]></FromUserName>
           <CreateTime>" . time() . "</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>7</ArticleCount>
           <Articles>
             <item>
           <Title><![CDATA[" . $form_Content . "空课室]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b400.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/H2ksGQKGimJX0HCjpYYhvUsgktYiiXYFR5vpbINTNGs!/b/dD7Vcu6dDgAA&bo=*gEFAgAAAAABAN8!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           ";

        for ($i = 1; $i <= 5; $i++) {
            $start = 2 * $i - 1;
            $stop = 2 * $i;
            $Title = "时间：" . $start . "、" . $stop . "节\n北座:\n" . $classroom[$i - 1]['NCLASSROOM'] . "\n南座:\n" . $classroom[$i - 1]['SCLASSROOM'] . "\n";
            $resultStr.="
           <item>
           <Title><![CDATA[$Title]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>";
        }

        $resultStr.="
            <item>
           <Title><![CDATA[输入【菜单】返回功能主页\n输入时间继续查询]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";


        $mc->set($fromUsername . "_do", "课室", 0, 1000);
        echo $resultStr;
        exit;
    } else {
        $mc->set($fromUsername . "_do", "课室", 0, 1000);
        $content = "你输入的时间有误，请输入 一、二、三……六、日，查询空课室或输【菜单】结束";
        $resultStr = sprintf($textTpl, $fromUsername, $toUsername, 'text', $content);
        echo $resultStr;
        exit;
    }
}
?>
